############################################################## 
## MOD Title: Comments in a popup window 
## MOD Author: isloera < isloera@yahoo.com > (Israel J. Sustaita)  www.calvilloweb.com
## MOD Description: This mod enables Coppermine to display the comments in a
## popup window. The number of comments available is shown as a link under the
## picture description, kind of like a blog does. 
##
## MOD Version: 1.0.1 
##
## Coppermine Version: CPG 1.4.3 and Up 
## 
## Installation Level: (Intermediate) 
## Installation Time: 20 Minutes 
## Files To Edit: 
##      displayimage.php, 
##      themes.inc.php,
##      delete.php, 
##      db_input.php,
##      english.php 
##
##      
## Included Files: (comments.php) 
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 

############################################################## 
## Author Notes: The popup generates valid HTML and CSS code. 
## It works with all the themes available  in  CPG 1.4.x  version                 
## Deleting, updating and posting  comments is done within the same popup window.
## It also respects group permissions and album settings.
## 
############################################################## 
## MOD History: 
## 
##   2006-01-22 - Version 1.0.1 
##      - Fixed a bug that stopped the popup link from showing
##        when there was no title and image description
## 
##   2006-01-22 - Version 1.0.0 
##      - Initial release 
## 
############################################################## 
## Before Adding This MOD To Your Gallery, You Should Back Up All Files Related To This MOD 
############################################################## 

 
# 
#-----[ COPY ]------------------------------------------ 
# 

copy root/comments.php to root/comments.php 

# 
#-----[ OPEN ]------------------------------------------ 
# 

displayimage.php

# 
#-----[  FIND  ]------------------------------------------ 
# LINE 306

$comments = theme_html_comments($CURRENT_PIC_DATA['pid']);

# 
#-----[ REPLACE WITH ]------------------------------------------ 
#

    // ***** commented because of the "comments in a popup window" mod
    //$comments = theme_html_comments($CURRENT_PIC_DATA['pid']);
    // ******* end of "comments in a popup window" mod
    
# 
#-----[ OPEN ]------------------------------------------ 
# 

include/themes.inc.php

# 
#-----[ FIND ]------------------------------------------ 
#AROUND LINE 711
                              
<!-- END img_desc -->

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

<!-- BEGIN comments_popup -->
							<table cellpadding="0" cellspacing="0" class="tableb" width="100%">
                                <tr>
                                        <td class="tableb" align="right">
                                                {COMMENTS_POPUP}
                                        </td>
                                </tr>
                         </table>
<!-- END comments_popup -->

# 
#-----[ FIND ]------------------------------------------ 
# LINE 1160

 <a id="v_xhtml" href="http://validator.w3.org/check/referer" target="_blank"></a>
      <a id="v_css" href="http://jigsaw.w3.org/css-validator/check/referer" target="_blank"></a>
</div>
EOT;

# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

// *********** "Comments in a popup window" mod ****************************

// HTML template for comments in a popup window 
if (!isset($template_comments_popup))  //{THEMES}
$template_comments_popup = <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="{LANG_DIR}">
<head>
<link rel="stylesheet" href="{THEME}style.css" type="text/css" />
<script type="text/javascript" src="scripts.js"></script>
<meta http-equiv="content-type" content="text/html; charset={CHARSET}" />
<title>{PAGE_TITLE}</title>
</head>
<body>


<!-- Start standard table -->
<table class="maintable" align="center" cellpadding="0" cellspacing="1" width="600">
   <tbody><tr><td class="navmenu" align="center" valign="middle" width="48">
   {HEADER}
      </td>
   </tr>
</tbody></table>
<!-- End standard table -->

<!-- Start standard table -->
<table class="maintable" align="center" cellpadding="0" cellspacing="0" width="600">
        <tbody>
              <tr>
                 <td class="display_media" align="center" nowrap="nowrap">
                        <table class="imageborder" cellpadding="0" cellspacing="2">
                                <tbody>
                                    <tr>
                                       <td align="center">                               
                                          <img src="{THUMBNAIL_PATH}" alt="{ALT_DESCP}" border="1" />
                                       </td>
                                   </tr>                                   
                          </tbody></table>
                  </td>
              </tr>
              <tr>
                 <td>
                 <!-- BEGIN img_desc -->
                        <table class="tableb" cellpadding="0" cellspacing="0" width="600">
<!-- BEGIN title -->
                           <tbody>
                            <tr>
                               <td class="tableb">                                   
                                   <center><b>{PIC_TITLE}</b></center>          
                               </td>
                            </tr>
<!-- END title -->
<!-- BEGIN caption -->
                            <tr>
                              <td class="tableb">                                   
                               <center>{PIC_CAPTION}</center>     
                              </td>
                            </tr>
<!-- END caption -->                              
                           </tbody></table>
<!-- END img_desc -->
                </td>
           </tr>
     </tbody></table>

<!-- End standard table -->

{COMMENTS}

</body>
</html>
EOT;

 if (!function_exists('pagecomments')) {  //{THEMES}
function pagecomments($meta = '',$pic,$comments)
{
    global $CONFIG, $THEME_DIR;
    global $template_comments_popup, $lang_charset, $lang_text_dir,$lang_comments_php;

    
    $thumb_path = $CONFIG['fullpath'].$pic['filepath'].'thumb_'.$pic['filename'];

    $charset = ($CONFIG['charset'] == 'language file') ? $lang_charset : $CONFIG['charset'];

   

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
    '{THEME}'           => $THEME_DIR,
    '{CHARSET}'         => $charset,
    '{PAGE_TITLE}'      => $lang_comments_php['comments'].'->'.$pic['title'],            
    '{HEADER}'          => $lang_comments_php['comments'],
    '{THUMBNAIL_PATH}'  => $thumb_path,    
    '{ALT_DESCP}'       => $pic['title'],
    '{PIC_TITLE}'       => $pic['title'],
    '{PIC_CAPTION}'     => bb_decode($pic['caption']),   
    '{COMMENTS}'        => $comments,

     );

    echo template_eval($template_comments_popup, $template_vars);
}
}  //{THEMES}
// ******* end of "comments in a popup window" mod **************

# 
#-----[ FIND ]------------------------------------------ 
# AROUND LINE 2078

    echo "<div id=\"comments\">\n";
        echo $comments;
        echo "</div>\n";
 
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#

// ***** commented because of the "comments in a popup window" mod
  /*echo "<div id=\"comments\">\n";
    echo $comments;
    echo "</div>\n";*/
// ******* end of "Comments in a popup window" mod
     
# 
#-----[ FIND ]------------------------------------------ 
# AROUND LINE 2109

global $lang_display_image_php, $lang_picinfo;
 
# 
#-----[ IN-LINE FIND ]------------------------------------------ 
# 

$lang_picinfo; 
 
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#

$lang_picinfo, $lang_display_comments;

# 
#-----[ FIND ]------------------------------------------ 
# AROUND LINE 2255

$CURRENT_PIC_DATA = CPGPluginAPI::filter('file_data',$CURRENT_PIC_DATA); 
 
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

  //**************** "Comments in a popup window" mod **************    
    $num_comms = count_pic_comments($pid);
        
    $text_mes = sprintf($lang_display_comments['comments'].' (<b>%d</b>)', $num_comms);  
     
     $comments_popup = '<a href="javascript:void(0)"
onclick="window.open(\'comments.php?pid='.$pid.'\',\'mywindow\',\'width=650,height=400,scrollbars=yes,toolbars=false,screenX=0,screenY=0,left=0,top=0\')" title="'.$lang_display_comments['click_here_tip'].'" >'.$text_mes .'</a>';

      //Let's hide the link to the popup when there are zero comments and the
      //user cannot post because of group permissions or because of the album's
      //settings
      if (((!USER_CAN_POST_COMMENTS) || ($CURRENT_ALBUM_DATA['comments'] =='NO'))
         && ($num_comms == 0))
      {   
			$comments_popup = '';
		}		
    //************ End of "Comments in a popup window" mod ****************

# 
#-----[ FIND ]------------------------------------------ 
#AROUND LINE 2278

        '{TITLE}' => bb_decode($CURRENT_PIC_DATA['title']),
 
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

        //**************** "Comments in a popup window" mod **************  
        '{COMMENTS_POPUP}' => $comments_popup,
        //**************** End of "Comments in a popup window" mod ********
     


# 
#-----[ OPEN ]------------------------------------------ 
# 

delete.php

# 
#-----[ FIND ]------------------------------------------ 
# AROUND LINE 400
   
		$redirect = "displayimage.php?pos=" . (- $comment_data['pid']); 
  
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
        //**************** "Comments in a popup window" mod **************  
        $redirect = "comments.php?pid=" . $comment_data['pid'];
        //**************** End of "Comments in a popup window" mod *********  
# 
#-----[ OPEN ]------------------------------------------ 
# 

db_input.php

# 
#-----[ FIND ]------------------------------------------ 
# AROUND LINE 101
   
$redirect = "displayimage.php?pos=" . (- $comment_data['pid']);
  
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
	//**************** "Comments in a popup window" mod **************  
	$redirect = "comments.php?pid=" . $comment_data['pid'];
	//**************** End of "Comments in a popup window" mod **********  
   
# 
#-----[ FIND ]------------------------------------------ 
#AROUND LINE 152
   
	$redirect = "displayimage.php?pos=" . (- $pid);
  
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
	//**************** "Comments in a popup window" mod **************  
	$redirect = "comments.php?pid=" .  $pid;
	//**************** End of "Comments in a popup window" mod **********  

# 
#-----[ FIND ]------------------------------------------ 
#AROUND LINE 166
   
	$redirect = "displayimage.php?pos=" . (- $pid);
  
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
	//**************** "Comments in a popup window" mod **************  
	$redirect = "comments.php?pid=" . $pid;
	//**************** End of "Comments in a popup window" mod ******* 

# 
#-----[ OPEN ]------------------------------------------ 
# IMPORTANT: These changes must be done in all the language files that you use

lang/english.php

# 
#-----[ FIND ]------------------------------------------ 
# AROUND LINE 1035
   
);

$lang_fullsize_popup = array(
  
# 
#-----[ BEFORE ADD ]------------------------------------------ 
#

  //**************** "Comments in a popup window" mod **************  
  'comments' => 'Comments',
  'click_here_tip' => 'Click here to read/post comments',  
  //**************** End of "Comments in a popup window" mod ******* 

# 
#-----[ FIND ]------------------------------------------ 
# AROUND LINE 1046
   
// ------------------------------------------------------------------------- //
// File ecard.php
// ------------------------------------------------------------------------- //
  
# 
#-----[ BEFORE ADD ]------------------------------------------ 
#

//**************** "Comments in a popup window" mod ************** 
// ------------------------------------------------------------------------- //
// File comments.php //cpg1.4
// ------------------------------------------------------------------------- //

if (defined('COMMENTS_PHP')) $lang_comments_php = array(
  'comments' => 'Comments', //cpg1.4  
  
);
//**************** End of "Comments in a popup window" mod *******

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM